<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel common\models\kingdee\HrPersonPhotoSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Hr Person Photos');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="hr-person-photo-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a(Yii::t('app', 'Create Hr Person Photo'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?php
    try {
        $gv = GridView::widget([
            'tableOptions' => ['class' => 'table table-condensed table-bordered table-striped table-hover'],
            'pager' => [
//            'class'          => GoPager::className(),
                'nextPageLabel'  => Yii::t('app', 'Next Page'),
                'prevPageLabel'  => Yii::t('app', 'Previous Page'),
                'firstPageLabel' => Yii::t('app', 'First Page'),
                'lastPageLabel'  => Yii::t('app', 'Last Page'),
                'options' => [
                    'class' => 'pagination pagination-sm m-t-none m-b-none',
                ],
            ],
            'dataProvider' => $dataProvider,
            'filterModel' => $searchModel,
            'columns' => [
                [
                    'class'         => 'yii\grid\ActionColumn',
                    'template'      => '{download} {view} {update} {delete}',
                    'header'        => '操作',
                    'headerOptions' => ['class' => 'text-center no-margin'],
                    'buttons'       => [
                        'download' => function($url, $model, $key) {
                            $options = [
                                'title' => Yii::t('app', 'Download'),
                                'data-id' => $key,
                                'target' => '_blank',
                            ];
                            return Html::a('<span class="	glyphicon glyphicon-download edit-class"></span>', '/kingdee/hr-person-photo/download?id='.$key, $options);
                        },
                    ],
                ],
                [
                    'class' => 'yii\grid\SerialColumn',
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 25px;'],
                ],
                [
                    'label' => Yii::t('app', 'Image Data'),
                    'attribute' => 'FIMAGEDATA',
                    'value'     => function ($model) {
                        return \common\business\EhrHelper::getPersonPhotoById($model['FID']);
                    },
                    'format' => [
                        'image',
                        [
                            'width'=>'35',
                            'height'=>'35'
                        ]
                    ],
//                'filter' => ArrayHelper::map(\common\models\kingdee\OrgAdmin::find()->all(), 'FID', 'FDISPLAYNAME_L2'),
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                ],
                [
                    'label' => Yii::t('app', 'Person Id'),
                    'attribute' => 'FPERSONID',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                ],
//                'FPERSONID',
                [
                    'label' => Yii::t('app', 'Image Height'),
                    'attribute' => 'FSOURCEIMAGEHEIGHT',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                ],
                [
                    'label' => Yii::t('app', 'Image Width'),
                    'attribute' => 'FSOURCEIMAGEWIDTH',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                ],
                // 'FIMAGECONTENTTYPE',
                // 'FIMAGEDATASOURCE',
//                [
//                    'label' => Yii::t('app', 'Image Data'),
//                    'attribute' => 'FIMAGEDATASOURCE',
//                    'value'     => function ($model) {
//                        return \common\business\EhrHelper::getPersonSourcePhotoById($model['FID']);
//                    },
//                    'format' => [
//                        'image',
//                        [
//                            'width'=>'35',
//                            'height'=>'35'
//                        ]
//                    ],
////                'filter' => ArrayHelper::map(\common\models\kingdee\OrgAdmin::find()->all(), 'FID', 'FDISPLAYNAME_L2'),
//                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
//                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
//                ],
                // 'FISINFILE',
                [
                    'attribute' => 'FID',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                ],
            ],
        ]);
    } catch (Exception $e) {
    }
    ?>
    <?= $gv ?>
</div>
